package serverdata;

public abstract class UniqueIdSing {
	public  uniqueid uid = null;
	public  String lockstring="lockstring";
	protected  uniqueid getuniqueid()
	{
		try
		{
			synchronized(lockstring)
			{
				if(uid==null)
				{
					uid = new uniqueid();
					int id = this.getcurrentid();
					this.setuniqueid(id);
				}
				return uid;
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
			return null;
		}
	}
	
	public int getnewid()
	{
		return this.getuniqueid().getid();
	}
	
	public abstract int getcurrentid();
	
	
	private boolean setuniqueid(int id)
	{
		return uid.setid(id);
	}
	
}
